﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QuanLyThietBi.DAL.Models;
using QuanLyThietBi.DAL;

namespace QuanLyThietBi.BLL
{
    public class ThietBiBO
    {
        /// <summary>
        /// Goi Ham luu thiet bi vao database
        /// </summary>
        /// <param name="tb"></param>
        /// <returns></returns>
        public int SaveThietBi(THIETBI tb)
        {
            ThietBiDAO tbDAO = new ThietBiDAO();
            return tbDAO.SaveThietBi(tb);
        }


        public int UpdateThietBi(THIETBI tb)
        {
            ThietBiDAO tbDAO = new ThietBiDAO();
            return tbDAO.UpdateThietBi(tb);
        }

        public int XoaThietBi(THIETBI tb)
        {
            ThietBiDAO tbDAO = new ThietBiDAO();
            return tbDAO.XoaThietBi(tb);
        }
        /// <summary>
        /// Goi ham lay het danh sach thiet bi
        /// </summary>
        /// <returns></returns>
        public List<THIETBI> GetAllThietBi()
        {
            ThietBiDAO tbDAO = new ThietBiDAO();
            return tbDAO.GetAllThietBi();
        }


        public int CountThietBi()
        {
            ThietBiDAO tbDAO = new ThietBiDAO();
            return tbDAO.CountThietBi();
        }

        // hàm search theo thiết bị
        public List<THIETBI> SearchThietBi(string tenthietbi,string mathietbi)
        {
            ThietBiDAO tbDAO = new ThietBiDAO();
            return tbDAO.GetThietBiForSearch(tenthietbi,mathietbi);
        }

        public List<THIETBI> SearchMaThietBi(string tenthietbi)
        {
            ThietBiDAO tbDAO = new ThietBiDAO();
            return tbDAO.GetMaThietBiForSearch(tenthietbi);
        }


        /// <summary>
        /// Lấy hết các thiết bị theo loại thiết bị
        /// </summary>
        /// <param name="loaiThietBiId"></param>
        /// <returns></returns>
        /// 
        public THIETBI GetThietBiById(int thietBiId)
        {
            ThietBiDAO tbDAO = new ThietBiDAO();
            return tbDAO.GetThietBiById(thietBiId);
        }


        public List<THIETBI> GetThietBiByLoaiThietBi(int loaiThietBiId)
        {
            ThietBiDAO tbDAO = new ThietBiDAO();
            return tbDAO.GetThietBiByLoaiThietBi(loaiThietBiId);
        }

        public List<THIETBI> GetThietBiChuaSuDung(int loaiThietBiId)
        {
            ThietBiDAO tbDAO = new ThietBiDAO();
            return tbDAO.GetThietBiChuaSuDung(loaiThietBiId);          
        }

        public THIETBI GetMaThietBi(int thiebiId)
        {
            ThietBiDAO tbDAO = new ThietBiDAO();
            return tbDAO.GetMaThietBi(thiebiId);  
        }
    }
}
